home *** CD-ROM | disk | FTP | other *** search
- Path: news.magi.com!news!news.magi.com
- From: nredding@magi.com (Neil Redding)
- Newsgroups: comp.lang.c
- Subject: Re: What the hell is THIS?!
- Date: Mon, 15 Jan 1996 16:26:36 -0500
- Organization: Magi Data Consulting
- Message-ID: <nredding-1501961626360001@magi03p10.magi.com>
- References: <4d6rgh$rfu@abel.cc.sunysb.edu> <coc-1301960253420001@dal1498.computek.net>
- NNTP-Posting-Host: magi03p10.magi.com
-
- In article <coc-1301960253420001@dal1498.computek.net>, coc@computek.net
- (Chad Cranfill) wrote:
-
- >In article <4d6rgh$rfu@abel.cc.sunysb.edu>, bmadhusu@engws12.ic.sunysb.edu
- >(Bommasamudram Madhusudan) wrote:
- >
- >> Can someone explain what
- >>
- >> int (*p)[3] is?????
- >>
- >
- >Starting with the "p", we parse the expression thusly: "p is an array of 3
- >pointers to int". If you need help with this (believe me, I did!) get the
- >book "Deep C Secrets". It presents an algorithmic method for decoding
- >statements like this, and gives hints on how to implement a C program that
- >will do this for you.
-
- I think you need to reread "Deep C Secrets". The above is actually "a
- pointer to array[3]
- of ints". This actual example is in K & R, Section 5.12, if you want to check.
-
- int *p[3] ( == *(p[3]) ) is "an array of 3 pointers to int".
- >
- >>
- >> I can say things like:
- >>
- >> (*p)[0] = 3; for e.g, but when I print the value using:
- >>
- >> printf("%d",(*p)[0]) I get a core dump!
- >
- It would be necessary to see the rest of the program to determine why it crashed
- at the printf. If p was a null pointer then (*p)[0]=3 could work but the printf
- statement would crash. See also "Deep C Secrets", Chapter 10.
-
- --
- Neil Redding
- Ottawa, Canada
-